﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using AspNetCs.Bll;
using AspNetCs.Common;
using AspNetCs.Model;

public partial class AjaxXml_OnlineUser_Ajax : BasePage
{
    protected Users u = new Users();
    protected int timeInt = 10;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!string.IsNullOrEmpty(Request["checktime"]))
        {
            timeInt = Convert.ToInt32(StringHelper.isNumber_decimal(Request["checktime"].ToString()) / 1000 / 60);

        }


        if (Base_GetLoginInfo.GetUserID != 0)
        {
            u.CheckUserOnline(" and Userid=" + Base_GetLoginInfo.GetUserID, timeInt);
        }

        if (SetCache.GetCache("Applicationtime") == null)
        {
            SetCache.SetCache("Applicationtime", DateTime.Now);
            u.CheckUserOnline("", timeInt);//更新所有没在线的用户
        }
        if (StringHelper.isNumber_int(Utils.DateDiff(Utils.DateInterval.Minute, StringHelper.isDatetime(SetCache.GetCache("Applicationtime")), DateTime.Now).ToString()) >= timeInt)
        {
            #region 用户当天登录增加积分

            if (Base_GetLoginInfo.GetUserID != 0)
            {
                Integral_Model md = new Integral_Model();
                md.Types = "Add";
                md.UserId = Base_GetLoginInfo.GetUserID;
                md.Readme = "用户(" + Base_GetLoginInfo.GetUserName + ")登录成功,增加积分";
                md.Num = configInfo.DayAddIntegral;
                Integral.CreateNew.Add(md);
            }
            #endregion


            SetCache.SetCache("Applicationtime", DateTime.Now);
            u.CheckUserOnline("", timeInt);//更新所有没在线的用户

        }
        // Response.Write(StringHelper.isNumber_int(Utils.DateDiff(Utils.DateInterval.Minute, StringHelper.isDatetime(SetCache.GetCache("Applicationtime")), DateTime.Now).ToString()));
    }
}
